const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('comKzzBaseInfo', {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: "编号"
    },
    zz_name: {
      type: DataTypes.STRING(12),
      allowNull: true,
      comment: "转债名称"
    },
    zz_code: {
      type: DataTypes.STRING(12),
      allowNull: true,
      comment: "代码"
    },
    current_bond_pricenew: {
      type: DataTypes.DECIMAL(20,4),
      allowNull: true,
      defaultValue: 0.0000,
      comment: "现价"
    },
    zz_zdf: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "涨跌"
    },
    stock_code: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: "",
      comment: "正股代码"
    },
    stock_name: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: "",
      comment: "正股名称"
    },
    stock_price: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "正股价"
    },
    stock_zdf: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "正股涨跌"
    },
    pbv_ratio: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "正股PB"
    },
    transfer_price: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "转股价"
    },
    transfer_value: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "转股价值"
    },
    transfer_premium_ratio: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "转股溢价率"
    },
    transfer_date_f242: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "开始转股日"
    },
    zz_ratio: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "纯债溢价率"
    },
    zz_pure_price_f424_f227: {
      type: DataTypes.DECIMAL(50,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "纯债价值"
    },
    bond_expire: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "期限"
    },
    newrate_refetence: {
      type: DataTypes.DECIMAL(50,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "票面利率(当期)"
    },
    rating: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: "0",
      comment: "评级"
    },
    first_per_preplacing: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "每股配售额"
    },
    ACTUAL_ISSUE_SCALE: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "发行亿"
    },
    resale_trig_price: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "回售触发价"
    },
    execute_price_hs: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "回售价"
    },
    redeem_trig_price: {
      type: DataTypes.DOUBLE(10,2),
      allowNull: true,
      defaultValue: 0.00,
      comment: "强赎价"
    },
    security_start_date: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "上市日"
    },
    expire_date: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "到期日"
    },
    execute_start_datehs: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "最新回售执行日"
    },
    create_time: {
      type: DataTypes.DATE,
      allowNull: true,
      defaultValue: Sequelize.Sequelize.literal('CURRENT_TIMESTAMP'),
      comment: "创建时间"
    },
    update_time: {
      type: DataTypes.DATE,
      allowNull: true,
      defaultValue: Sequelize.Sequelize.literal('CURRENT_TIMESTAMP'),
      comment: "更新时间"
    },
    base_info_date: {
      type: DataTypes.DATE,
      allowNull: true,
      defaultValue: "2020-03-15 00:00:00",
      comment: "基本面更新日期"
    },
    base_info_detail: {
      type: DataTypes.DATE,
      allowNull: true,
      defaultValue: "2020-02-02 00:00:00",
      comment: "基本面详情更新日期"
    }
  }, {
    sequelize,
    tableName: 'com_kzz_base_info',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
